package rs.mbs2.epics.server.session.dao.bean;

import java.util.List;

import javax.ejb.Local;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;
import javax.persistence.Query;

import rs.mbs2.epics.server.entity.Rating;
import rs.mbs2.epics.server.session.dao.localinterface.RatingDaoLocal;

@Stateless
@Local(RatingDaoLocal.class)
@TransactionManagement(TransactionManagementType.CONTAINER)
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class RatingDaoBean extends GenericDaoBean<Rating, Integer> implements RatingDaoLocal {
	
	@Override
	public List<Rating> findRatingByPhotoAndUser(Integer photoId, Integer userId) {
		
		Query q = em.createNamedQuery("findRatingByPhotoAndUser");
		q.setParameter("photoId", photoId.toString());
		q.setParameter("userId", userId.toString());		
		
		@SuppressWarnings("unchecked")
		List<Rating> res = q.getResultList();
		
		return res;
	}


}
